#define _CRT_SECURE_NO_WARNINGS 1


#include<stdio.h>

struct ListNode
{
    int val;
    ListNode* next;
};

typedef struct ListNode ListNode;

int ListSize(ListNode* phead)
{
    int size = 0;
    ListNode* pcur = phead;
    while (pcur)
    {
        size++;
        pcur = pcur->next;
    }
    return size;
}

struct ListNode* findKthToTail(struct ListNode* pListHead, int k)
{
    if (pListHead == NULL)
    {
        return NULL;
    }
    int end = ListSize(pListHead) - k;
    if (end < 0)
    {
        return NULL;
    }
    ListNode* pcur = pListHead;
    while (end--)
    {
        pcur = pcur->next;
    }
    return pcur;
}